import config from 'config'
import httpFetch from 'share/httpFetch'
import errorMessage from "share/errorMessage";

export default {
  getSubModule(){
    return httpFetch.get(`${config.baseUrl}/mobile/api/module/list`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },
  getSubAppList(moduleId){
    return httpFetch.get(`${config.baseUrl}/mobile/api/management/widget/tenant/all/v2?moduleId=${moduleId}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },
  updateSubApp(params){
    return httpFetch.post(`${config.baseUrl}/api/widget/draftWidget`, params)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },
  getFunctionOptions(){
    return httpFetch.get(`${config.baseUrl}/api/resource/detail/list/relevance`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },
  //获取首页卡片应用详情
  getHomePageCardDetail () {
    return httpFetch.get(`${config.baseUrl}/mobile/api/management/config/tenant`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },
  //编辑首页卡片应用详情
  editHomePageCardDetail (item) {
    return httpFetch.post(`${config.baseUrl}/mobile/api/management/config/tenant`, item)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },

  //管理端 获取当前租户下对应section可用列表
  getSectionList (sectionCode) {
    return  httpFetch.get(`${config.baseUrl}/mobile/api/management/widget/${sectionCode}`)
      .catch(err => {
        errorMessage(err.response);
        throw err;
      })
  },
}
